﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PBOffice.BLL;

public partial class FilesPage_FileRecycle : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ((ScriptManager)Master.FindControl("ScriptManager1")).RegisterPostBackControl(GridViewRecycleFileList);
        GridViewRecycleFileList.DataSource = FileOperationBLL.SelectAlllRecycle();
        GridViewRecycleFileList.DataBind();
    }
    protected void DocName_Click(object sender, EventArgs e)
    {

    }
    protected void manage_Click(object sender, ImageClickEventArgs e)
    {

    }
    protected void deleted_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton btn = sender as ImageButton;
        int rowindex = ((GridViewRow)btn.NamingContainer).RowIndex;
        string docNo = ((GridViewRecycleFileList.Rows[rowindex].FindControl("DocId")) as Label).Text;
        if (FileOperationBLL.SelectFilesSon(Convert.ToInt32(docNo)))
        {
            if (FileOperationBLL.DeltedFile(Convert.ToInt32(docNo),Server.MapPath("~/UserFiles")))
            {
                Response.Write("<script>alert('我已经把它扔了');window.location.href='FileRecycle.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('哎呀，不好意思失败了。在试试看');window.location.href='FileRecycle.aspx'</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('该文件下存在别的文件，请先删除别的文件');window.location.href='FileRecycle.aspx'</script>");
        }

    }
    protected void upcancel_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton btn = sender as ImageButton;
        int RowIndex = ((GridViewRow)btn.NamingContainer).RowIndex;
        string docNo = ((GridViewRecycleFileList.Rows[RowIndex].FindControl("DocId")) as Label).Text;
        if (FileOperationBLL.Upcancel(Convert.ToInt32(docNo)))
        {
            Response.Write("<script>alert('恢复成功了');window.location.href='ShowFiles.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('恢复失败');window.location.href='FileRecycle.aspx'</script>");
        }
    }
}